import request from '../utils/request'

interface IdentityApi {
  // 提交实名认证
  verifyIdentity: (data: {
    realName: string
    idCardNumber: string
    idCardFront: File
    idCardBack: File
    faceImage: File
  }) => Promise<any>
  
  // 获取认证状态
  getVerificationStatus: () => Promise<any>
  
  // 管理员审核（可选）
  approveVerification: (data: {
    verificationId: string
    action: 'approved' | 'rejected'
    reason?: string
  }) => Promise<any>
}

export const identityApi: IdentityApi = {
  // 提交实名认证
  verifyIdentity: (data) => {
    const formData = new FormData()
    formData.append('realName', data.realName)
    formData.append('idCardNumber', data.idCardNumber)
    formData.append('idCardFront', data.idCardFront)
    formData.append('idCardBack', data.idCardBack)
    formData.append('faceImage', data.faceImage)
    
    return request.post('/identity/verify', formData)
  },
  
  // 获取认证状态
  getVerificationStatus: () => {
    return request.get('/identity/status')
  },
  
  // 管理员审核
  approveVerification: (data) => {
    return request.post('/identity/approve', data)
  }
}

